import Vue from 'vue';
import VueRouter from 'vue-router';
import layout from '@/components/layout/layoutIndex.vue'
import login from '@/components/login/loginIndex.vue'
import home from '@/components/home/homeIndex.vue'
Vue.use(VueRouter);

const routes = [
    {
        path: '/',
        component:layout,
        children:[
            {
                path: '/',
                name: 'home',
                component:home
            },{
                path: '/product',
                name: 'product',
                component: () => import('@/components/product/productIndex.vue'),/* 懒加载的方式配置路由 */
                children:[
                    {
                        path: 'list',
                        name: 'productList',
                        component: () => import('@/components/product/list/listIndex.vue')
                    },
                    {
                        path : 'category',
                        name : 'productCategory',
                        component: () => import('@/components/product/category/categoryIndex.vue')
                    }
                ]
            },
            {
                path: '/order',
                name: 'order',
                component:() =>import ('@/components/order/orderIndex.vue'),
                children:[
                    {
                        path: 'order-list',
                        name: 'orderList',
                        component: () => import('@/components/order/list/listIndex.vue')
                    },
                    {
                        path: 'collect',
                        name: 'collect',
                        component: () => import('@/components/order/collect/collectIndex.vue')
                    }
                ]
            },
            {
                path: '/advert',
                name: 'advert',
                component: () => import('@/components/advert/advertIndex.vue'),
                children:[
                    {
                        path: 'advert-list',
                        name: 'advertList',
                        component: () => import('@/components/advert/list/listIndex.vue')
                    }
                ]
            }
        ]
    },
    {
        path: '/login',
        name : 'login',
        component: login
    },
    
    
]

const router = new VueRouter({
    mode: 'history',
    routes
})
export default router;